cmake_minimum_required(VERSION 3.8)
project(cudalib CUDA)

#find_package(CUDA)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

set(MKL_INTERFACE lp64)
find_package(MKL CONFIG REQUIRED PATHS $ENV{MKLROOT})

find_package (OpenMP)

# Add library target
add_library(cudalib 
    STATIC  
        solver.cu
        common.cuh 
        cpu_blas.h 
        gpu_blas.cuh 
        utilities.cuh
        inversion.cuh
        inversion.cu
        blocklu.cuh 
        blocklu.cu
        lutrtri.cuh 
        lutrtri.cu
)

#target_include_directories(cudalib PUBLIC ${CUDA_INCLUDE_DIRS})
target_include_directories(cudalib 
    PUBLIC 
        ${CUDA_INCLUDE_DIRS}
        $<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>
)

target_link_directories(cudalib PUBLIC "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64")

target_link_libraries(cudalib
    PUBLIC
        cusolver
        cudart_static
        cublas
        cublasLt
        cusparse
        $<LINK_ONLY:MKL::MKL>
)

set_target_properties(cudalib PROPERTIES CUDA_ARCHITECTURES "75")

target_compile_options(cudalib PRIVATE ${CUDA_ARCHITECTURE_FLAGS} "--use_fast_math")
